package com.lbn.monitor.app.account;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.Toast;

import com.lbn.monitor.R;
import com.lbn.monitor.base.AppBaseActivity;
import com.lbn.monitor.widget.Appbar;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class CpwActivity extends AppBaseActivity<CpwPresenter> implements ICpwView {

    @BindView(R.id.old_password)
    EditText oldPassword;
    @BindView(R.id.new_password)
    EditText newPassword;
    @BindView(R.id.confirm_password)
    EditText confirmPassword;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cpw);
        ButterKnife.bind(this);
        setAppbar(new Appbar(this)
                .openBack()
                .setTitle("修改密码"));
    }

    @Override
    protected CpwPresenter createPresenter() {
        return new CpwPresenter();
    }

    @Override
    protected void onPresenterCreated() {
        super.onPresenterCreated();
    }

    public static void startActivity(Context context) {
        context.startActivity(new Intent(context, CpwActivity.class));
    }

    @Override
    public void onSucceed() {
        Toast.makeText(this, "修改密码成功", Toast.LENGTH_SHORT).show();
        finish();
    }

    public String getOldPassword() {
        return oldPassword.getText().toString();
    }

    public String getNewPassword() {
        return newPassword.getText().toString();
    }

    public String getConfirmPassword() {
        return confirmPassword.getText().toString();
    }

    @OnClick(R.id.pay)
    public void onClick() {
        mPresenter.pwd(getOldPassword(),getNewPassword(),getConfirmPassword());
    }
}
